//Nic Lupfer
#include <string>
#include <vector>
#include "table.h"

using namespace std;

enum QTokenType{
	tkOpenPar,
	tkClosePar,
	tkAnd,
	tkOr,
	tkNot,
	tkIn,
	tkExists,
	tkEquals,
	tkNotEquals,
	tkLessThan,
	tkLessThanEq,
	tkGreatThan,
	tkGreatThanEq,
	tkAll,
	tkAny,
	tkValue,
	tkExp,
	tkAs,
	tkStar,
	tkSum,
	tkMin,
	tkMax,
	tkCount
};

struct Token{
	QTokenType type;
	string value;
	vector<Record*> records;
};

class Query{
	
	private:
		Table* table;
		int numQuery;

		vector<Record*> inExp(string attribute, string value, vector<Table*> tables);

		vector<Record*> existsExp(string value, vector<Table*> tables);

		vector<Record*> allExp(string attribute, QTokenType tk, string value, vector<Table*> tables);

		vector<Record*> anyExp(string attribute, QTokenType tk, string value, vector<Table*> tables);

		vector<Record*> expression(string attribute, QTokenType tk, string value, vector<Table*> tables);

		vector<Record*> and(vector<Record*> a, vector<Record*> b);

		vector<Record*> or(vector<Record*> a, vector<Record*> b);

		vector<Record*> not(vector<Record*> a, vector<Table*> tables);

		QTokenType Query::isTokenType(string s);

		void deepCopyRecord(Table*,Record*to,Record*from,int column);

	public:
		Query();

		Query(Table* t);

		string doQuery(string from, string wher, string select);

		vector<Record*> find(string from, string wher);

		vector<Table*> From(string from);

		vector<Record*> Where(string wher, vector<Table*>);

		Table* Select(string select, vector<Record*>, vector<Table*>);
		
		string RemoveSpace(string);

		//bool whereStatement(string operation, Table* t, Record* r);


	
};



